<?php
/*提供给管理员使用的页面，可以查看所有用户的个人资料*/
/* @var $this yii\web\View */
use yii\helpers\Html;
use app\models\Member;
use yii\helpers\Url;
use app\models\MemberActivity;
use yii\widgets\ListView;
use yii\grid\GridView;
use yii\data\ActiveDataProvider;
use app\assets\ChartAsset;
ChartAsset::register($this);

$this->title = '会员个人资料';
$this->params['breadcrumbs'][] = $this->title;
$tjr_dataProvider = new ActiveDataProvider([
    'query' => Member::find()->where(['tjr'=>$model->name]),
    'pagination' => [
        'pageSize' => 20,
    ],
]);

$activity_dataProvider = new ActiveDataProvider([
    'query' => MemberActivity::find()->where(['member_id'=>$model->id]),
    'pagination' => [
        'pageSize' => 20,
    ],
]);
?>
<div class="page-title">
  <div>
    <h1><i class="fa fa-user"></i> 会员个人资料</h1>
    <ul class="breadcrumb side">
      <li><i class="fa fa-home fa-lg"></i></li>
      <li><span>会员管理</span></li>
      <li><a href="<?=Url::toRoute('site/users')?>">查看会员信息</a></li>
      <li class="active"><a href="#"><?=Html::a($model->name, '#')?></a></li>
    </ul>
  </div>
  <div><a class="btn btn-info btn-flat" href="<?=Url::toRoute('site/editprofile')?>"><i class="fa fa-lg fa-edit"></i> 修改资料</a></div>
</div>
<div class="card" role="main">
  <div class="">

    <div class="row">
      <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
          <div class="x_content">
            <div class="col-md-3 col-sm-3 col-xs-12 profile_left">
              <div class="profile_img">
                <div id="crop-avatar">
                  <!-- Current avatar -->
                  <img class="img-responsive avatar-view" src="images/timg3.jpg" alt="Avatar" title="Change the avatar" style="width:200px;height:200px;">
                </div>
              </div>
              <h3><?=Html::encode($model->name)?></h3>

              <ul class="list-unstyled user_data">
                <li><span style="width:20px;display:inline-block;"><i class="fa fa-phone-square user-profile-icon"></i></span> <?=Html::encode($model->phone)?>
                </li>

                <li>
                  <span style="width:20px;display:inline-block;"><i class="fa fa-leaf user-profile-icon"></i></span> <?=Html::encode($model->tjm)?>
                </li>

                <li class="m-top-xs">
                  <span style="width:20px;display:inline-block;"><i class="fa fa-dollar user-profile-icon"></i></span> <?=Html::encode($model->nea_count)?>
                </li>
                <li class="m-top-xs">
                  <span style="width:20px;display:inline-block;"><i class="fa fa-area-chart user-profile-icon"></i></span> <?=Html::encode($model->usd_count)?>
                </li>
              </ul>


              <br />

              <!-- start skills -->
              <div class="">
                <h3 class="card-title">推荐会员</h3>
                <?php
                  echo ListView::widget([
                    'dataProvider' => $tjr_dataProvider,
                    'itemView' => '_tjritem',
                  ]);
                ?>
              </div>
              <!-- end of skills -->

            </div>
            <div class="col-md-9 col-sm-9 col-xs-12">

              <div class="row">
                  <div class="col-md-6">
                    <div class="embed-responsive embed-responsive-16by9">
                      <canvas class="embed-responsive-item" id="lineChartDemo1"></canvas>
                    </div>
                  </div>
                  <div class="col-md-6">
                    <div class="embed-responsive embed-responsive-16by9">
                      <canvas class="embed-responsive-item" id="lineChartDemo2"></canvas>
                    </div>
                  </div>
              </div>



<h3 class="card-title">最近的活动</h3>
                    <!-- start user projects -->
                    <?php
                    //如何提前加载资源
                    echo GridView::widget([
                    'dataProvider' => $activity_dataProvider,
                    'columns' => [
                    ['class' => 'yii\grid\SerialColumn'],
                    // 数据提供者中所含数据所定义的简单的列
                    // 使用的是模型的列的数据
                    'dt',
                    'type',
                    'ip',
                    'activity_info',
                    ],
                    'tableOptions' => [
                      'class' => 'table table-striped'
                    ],
                    ]);
                    ?>

                    <!-- end user projects -->


                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
